import i18n from '@/i18n';
import menuLayout from '@/layout/menuLayout.vue';
import systemLayout from '@/layout/systemLayout.vue';
import type { RouteRecordRaw } from 'vue-router';

const { t } = i18n.global;

const allRoles = [
	'account',
	'role',
	'device',
	'pointTable',
	'normalization',
	'northPointTable',
	'indicator',
	'warningSet',
	'overlimitWarning',
	'stationParams',
	'logManage',
	'about',
];

const systemRouter: RouteRecordRaw = {
	path: '/system',
	component: menuLayout,
	meta: { roles: allRoles },
	children: [
		{
			path: '/system',
			component: systemLayout,
			redirect: '/system/account',
			meta: { roles: allRoles },
			children: [
				{
					path: 'account',
					name: 'account',
					component: () => import('@/views/system/account/index.vue'), // 账户管理
					meta: {
						title: t('menu.account'),
						roles: ['account'],
						show: true,
						menu: 'system',
					},
				},
				{
					path: 'role',
					name: 'role',
					component: () => import('@/views/system/role/index.vue'), // 角色管理
					meta: { title: t('menu.role'), roles: ['role'], show: true, menu: 'system' },
				},
				{
					path: 'device',
					name: 'device',
					component: () => import('@/views/system/device/index.vue'), // 设备管理
					meta: {
						title: t('menu.device'),
						roles: ['device'],
						show: true,
						menu: 'system',
					},
				},
				{
					path: 'dictionary',
					name: 'dictionary',
					component: () => import('@/views/system/dictionary/index.vue'), // 数据字典
					meta: { title: '数据字典', roles: ['account'], show: false, menu: 'system' },
				},
			],
		},
	],
};

export default systemRouter;
